NodeController
The NodeController manages SWMM network nodes (junctions, outfalls, storage units, etc.) and provides access to node data, attributes, and simulation results.
Overview
This controller handles all node-related operations including retrieving node definitions, time series data, and simulation results. It integrates with Azure storage services to provide comprehensive node information for the SWMM network model.
Data Sources
- Azure Blob Storage:
networkmodelcontainer for node definitionsswmm-outputcontainer for simulation results
- Azure Table Storage:
Runstable for run metadataNodeOutputtable for node time series data
- Configuration:
appsettings.jsonfor connection string
Endpoints
GET /api/node/nodes
Retrieves all network nodes with their properties and geographic coordinates.
Response:
- 200 OK: Returns JSON string containing node definitions
- 500 Internal Server Error: Storage or processing error
Data Flow:
Node Data Structure:
[
["index", "index", "NodeType", "longitude", "latitude"],
["0", "0", "JUNCTION", "-87.6298", "41.8781"],
["1", "1", "OUTFALL", "-87.6299", "41.8782"]
]
Node Array Format:
- Index 0: Node index
- Index 1: Node index (duplicate)
- Index 2: Node type (JUNCTION, OUTFALL, STORAGE, DIVIDER)
- Index 3: Longitude
- Index 4: Latitude
GET /api/node/values
Retrieves time series data for a specific node attribute.
Query Parameters:
index(string): Node indexrunDateTime(string): Simulation run datetimemeasurementIndex(string): Attribute type (depth, flow, etc.)scenario(string): Scenario name
Response:
- 200 OK: Returns time series as JSON array
[[timestamp, value], ...] - 404 Not Found: Node or run not found
- 500 Internal Server Error: Processing error
Data Flow:
Time Series Processing:
- Converts simulation time steps to Unix timestamps (milliseconds)
- Uses reporting time step from run configuration
- Handles timezone conversions
- Returns array of
[timestamp, value]pairs
GET /api/node/results
Retrieves simulation results for a specific node at a given timestep.
Query Parameters:
step(string): Simulation timesteprunDateTime(string): Simulation run datetimenodeIndex(string): Node index
Response:
- 200 OK: Returns
SwmmNodeResultobject - 404 Not Found: Results not found
- 500 Internal Server Error: Processing error
Data Flow:
Azure Storage Details
Blob Containers
networkmodel: Contains node definitionsswmm-output: Contains simulation results by timestep
Table Storage
Runs: Run metadata and parametersNodeOutput: Node time series dataErrors: Error logging
Blob Structure
networkmodel/
├── {partitionKey}/
│ └── nodes
swmm-output/
├── {partitionKey}_{scenario}_{datetime}/
│ ├── {step}
│ └── ...
Data Models
Node Definition
public class NodeDefinition
{
public string Index { get; set; }
public string Type { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
}
Node Result
public class SwmmNodeResult
{
public double Depth { get; set; }
public double Head { get; set; }
public double Inflow { get; set; }
public double Overflow { get; set; }
public double Quality { get; set; }
}
Time Series Point
public class TimeSeriesPoint
{
public long Timestamp { get; set; } // Unix milliseconds
public double? Value { get; set; }
}
Configuration
Required Settings:
{
"Values": {
"CloudStorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net"
}
}
Error Handling
- Storage Errors: Logged to Azure Table Storage
- Missing Data: Returns null or empty arrays
- Invalid Parameters: Graceful parameter validation
- Time Processing: Handles timezone and format issues
Performance Considerations
- Memory Management: Uses memory streams for blob operations
- Data Parsing: Efficient string parsing for large datasets
- Caching: No built-in caching (consider for frequently accessed data)
- Time Conversion: Optimized timestamp calculations
Dependencies
Azure.Storage.BlobsAzure.Data.TablesGqcStorage1(Storage utilities)SwmmUtilities(Time series processing)SwmmModels(Data models)
Common Node Types
- JUNCTION: Standard junction node
- OUTFALL: Outfall/discharge point
- STORAGE: Storage unit/basin
- DIVIDER: Flow divider
Time Series Processing
- Unix Timestamps: Converts to milliseconds since epoch
- Time Steps: Uses reporting time step from run configuration
- Time Windows: Supports start/end time filtering
- Data Validation: Handles null/missing values
Common Node Attributes
- Depth: Water depth at node
- Head: Hydraulic head
- Inflow: Total inflow to node
- Overflow: Overflow from node
- Quality: Water quality parameters
Usage Examples
Get All Nodes:
GET /api/node/nodes
Get Node Time Series:
GET /api/node/values?index=0&runDateTime=2023-11-16T00:00:00-05:00&measurementIndex=0&scenario=scenario0
Get Node Results:
GET /api/node/results?step=15&runDateTime=2023-11-16T00:00:00-05:00&nodeIndex=0